package com.pomr.model.equipmentstorage;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pomr.model.synthesize.Equipment;
import com.pomr.model.synthesize.Manufacturer;
import com.pomr.model.sys.Agency;
import com.pomr.model.sys.User;

/**
 * 设备入库表
 * @author Administrator
 *
 */
@Entity
@Table(name="equipmentinstorage")
public class EquipmentInStorage implements Serializable{

	

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getSpecification() {
		return specification;
	}

	public void setSpecification(String specification) {
		this.specification = specification;
	}

	public String getCreateUserName() {
		return createUserName;
	}

	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}

	public String getImeiprefix() {
		return imeiprefix;
	}

	public void setImeiprefix(String imeiprefix) {
		this.imeiprefix = imeiprefix;
	}

	public String getImeisuffix() {
		return imeisuffix==null?"":imeisuffix;
	}

	public void setImeisuffix(String imeisuffix) {
		this.imeisuffix = imeisuffix;
	}

	public String getImeistartSN() {
		return imeistartSN==null?"":imeistartSN;
	}

	public void setImeistartSN(String imeistartSN) {
		this.imeistartSN = imeistartSN;
	}

	public String getImeiendSN() {
		return imeiendSN==null?"":imeiendSN;
	}

	public void setImeiendSN(String imeiendSN) {
		this.imeiendSN = imeiendSN;
	}

	public String getPrefix() {
		return prefix==null?"":prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}

	public String getSuffix() {
		return suffix==null?"":suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	public String getEquipmentName() {
		return equipmentName;
	}

	public void setEquipmentName(String equipmentName) {
		this.equipmentName = equipmentName;
	}

	public String getManufacturerName() {
		return manufacturerName;
	}

	public void setManufacturerName(String manufacturerName) {
		this.manufacturerName = manufacturerName;
	}

	public String getAgencyName() {
		return agencyName;
	}

	public void setAgencyName(String agencyName) {
		this.agencyName = agencyName;
	}

	public String getInUserName() {
		return inUserName;
	}

	public void setInUserName(String inUserName) {
		this.inUserName = inUserName;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Equipment getEquipment() {
		return equipment;
	}

	public void setEquipment(Equipment equipment) {
		this.equipment = equipment;
	}

	public Manufacturer getManufacturer() {
		return manufacturer;
	}

	public void setManufacturer(Manufacturer manufacturer) {
		this.manufacturer = manufacturer;
	}

	public Agency getAgency() {
		return agency;
	}

	public void setAgency(Agency agency) {
		this.agency = agency;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public Integer getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	public String getStartSN() {
		return startSN==null?"":startSN;
	}

	public void setStartSN(String startSN) {
		this.startSN = startSN;
	}

	public String getEndSN() {
		return endSN==null?"":endSN;
	}

	public void setEndSN(String endSN) {
		this.endSN = endSN;
	}

	public Date getInTime() {
		return inTime;
	}

	public void setInTime(Date inTime) {
		this.inTime = inTime;
	}

	public User getInUser() {
		return inUser;
	}

	public void setInUser(User inUser) {
		this.inUser = inUser;
	}

	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")//AUTO 在mysql中需要指定使用本地策略生成主键值
	private Integer id;//主键
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="equipment_id")
	private Equipment equipment;//设备主键
	
	@Formula("(select me.name from menu_equipment me where me.id=( select e.kind_id from equipment e where e.id=equipment_id))")
	private String equipmentName;//设备名称
	
	@Formula("(select e1.specification from equipment e1 where e1.id=equipment_id)")
	private String specification;//设备型号
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="manufacturer_id")
	private Manufacturer manufacturer;//厂商主键
	
	@Formula("(select m.name from manufacturer m where m.id=manufacturer_id)")
	private String manufacturerName;//厂商名称
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="agency_id")
	private Agency agency;//机构主键
	
	@Formula("(select a.name from agency a where a.id=agency_id)")
	private String agencyName;//机构名称
	
	@Column(name="price",columnDefinition="double(10,2) default '0.00'")
	private double price;//价格
	
	@Column(name="number")
	private Integer number;//数量
	
	@Column(name="prefix",length=20)
	private String prefix;//SN码前置
	@Column(name="suffix",length=20)
	private String suffix;//SN码后置
	
	@Column(name="startSN",length=20)
	private String startSN;//起始SN码
	
	@Column(name="endSN",length=20)
	private String endSN;//结束SN码
	
	@Column(name="imei_prefix",length=20)
	private String imeiprefix;//IMEI前置
	@Column(name="imei_suffix",length=20)
	private String imeisuffix;//IMEI后置
	
	@Column(name="imei_startSN",length=20)
	private String imeistartSN;//起始IMEI
	
	@Column(name="imei_endSN",length=20)
	private String imeiendSN;//结束IMEI
	
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
	@Column(name="inTime")
	private Date inTime;//入库日期
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="inUser")
	private User inUser;//入库人员id
	
	@Formula("(select u.name from user u where u.id=inUser)")
	private String inUserName;//入库人姓名
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="createUser")
	private User createUser;//创建人员id
	
	@Formula("(select u1.name from user u1 where u1.id=createUser)")
	private String createUserName;//创建人姓名
	
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
	@Column(name="createTime")
	private Date createTime;//创建日期
	
	@Column(name="state")
	private String state;//状态 1审核通过
	
	@Column(name="remark",length=200)
	private String remark;//备注

}
